package com.model.oneToOne;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;

import com.model.Status;

@Entity
@Table(name = "TB_LOGIN")
public class Login {

	@Id
	@GenericGenerator(name = "generator", strategy = "increment")
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false)
	private int id;
	
	@Column(name = "NAME", length = 30, nullable = false)
	private String name;
	
	@Column(name = "PASS", length = 40, nullable = false)
	private String pass;
	
	@Enumerated(EnumType.STRING)
	@Column(name = "STATUS", nullable = false, columnDefinition = "varchar(20) default 'CANCEL'")
	private Status status;
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USER_ID")
	@Cascade(value = { CascadeType.SAVE_UPDATE, CascadeType.DELETE})
	private User user;
	
	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
